package com.onstar.cn.framework.test;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import com.onstar.cn.framework.R;

public class FragmentTestActivity extends FragmentActivity {
	public void changeFragment(FragmentManager fragmentManager, Fragment fragment, String tag, boolean initialize) {
		FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
		fragmentTransaction.replace(R.id.fragment_container, fragment, tag);
		fragmentTransaction.addToBackStack(null);
		// if (fragmentManager.findFragmentByTag(tag) == null) {
		// if (!tag.equals(new MapFragment().getFragmentTag())) {
		// fragments.add(fragment);
		// }
		// }
		fragmentTransaction.commitAllowingStateLoss();
	}

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.fragment_container);
		changeFragment(getSupportFragmentManager(), new FragmentTest(), "fragment", true);
	}

}
